<template>
  <page-header-wrapper>
    <global-search ref="globalSearch" :list="searchList" @search="handleSearch" @reset="handleReset"> </global-search>
    <a-card :bordered="false">
      <s-table
        ref="table"
        size="default"
        :rowKey="(record, index) => index"
        :columns="columns"
        :data="loadData"
        :pagination="{ showTotal: (total) => `共 ${total} 条` }"
        :scroll="{ x: true }"
      >
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }} </span>
        <ellipsis slot="ellipsis" :length="32" slot-scope="text">{{ text || '/' }}</ellipsis>
        <span slot="empty" slot-scope="text">{{ text || '/' }}</span>
        <span slot="time" slot-scope="text">{{ text | moment('YYYY-MM-DD') }}</span>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { getStatementList } from '@/api/statementAndStatistics'
export default {
  components: {
    STable,
    Ellipsis
  },
  data () {
    return {
      searchList: [
        {
          label: '时间',
          fields: 'ESetDate',
          type: 'range'
        }
      ],
      queryParam: {
        Mode: 'OutAllSeniority',
        UserID: this.$store.getters.userid,
        strContent: {}
      },
      columns: [
        {
          title: '序号',
          align: 'center',
          width: '80px',
          scopedSlots: { customRender: 'index' }
        },
        {
          title: '姓名',
          align: 'center',
          dataIndex: 'Proposer'
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'IDcard'
        },
        {
          title: '保障方式',
          align: 'center',
          dataIndex: 'ApplyClass'
        },
        {
          title: '补贴方式',
          align: 'center',
          dataIndex: 'CityVfyAssign'
        },
        {
          title: '审批结果',
          align: 'center',
          dataIndex: 'CityRfyResult'
        },
        {
          title: '区级部门名称',
          align: 'center',
          dataIndex: 'RegionName',
          scopedSlots: { customRender: 'ellipsis' }
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'ProjectName',
          scopedSlots: { customRender: 'ellipsis' }
        },
        {
          title: '安置点详细信息',
          align: 'center',
          dataIndex: 'ESitesSelect',
          scopedSlots: { customRender: 'ellipsis' }
        },
        {
          title: '房屋状态',
          align: 'center',
          dataIndex: 'HousesMode',
          scopedSlots: { customRender: 'empty' }
        },
        {
          title: '原因',
          align: 'center',
          dataIndex: 'AlterInfo',
          scopedSlots: { customRender: 'ellipsis' }
        },
        {
          title: '操作人姓名',
          align: 'center',
          dataIndex: 'UserName',
          scopedSlots: { customRender: 'empty' }
        },
        {
          title: '分配时间',
          align: 'center',
          dataIndex: 'ESetDate',
          scopedSlots: { customRender: 'time' }
        },
        {
          title: '合同签订时间',
          align: 'center',
          dataIndex: 'actDate',
          scopedSlots: { customRender: 'time' }
        },
        {
          title: '确认情况',
          align: 'center',
          dataIndex: 'IfQueue',
          scopedSlots: { customRender: 'empty' }
        },
        {
          title: '确认人',
          align: 'center',
          dataIndex: 'QueueAgent',
          scopedSlots: { customRender: 'empty' }
        },
        {
          title: '确认时间',
          align: 'center',
          dataIndex: 'QueueDate',
          scopedSlots: { customRender: 'time' }
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getStatementList(requestParameters).then((res) => res)
      }
    }
  },
  methods: {
    handleSearch (values) {
      const { ESetDate } = values
      if (Array.isArray(ESetDate)) {
        this.queryParam.strContent.sESetDate = ESetDate[0]
        this.queryParam.strContent.eESetDate = ESetDate[1]
      }
      this.tableRefresh(true)
    },
    handleReset () {
      this.queryParam.strContent = {}
      this.tableRefresh(true)
    },
    tableRefresh (refresh = false) {
      this.$refs.table.refresh(refresh)
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .ant-table {
  tr,td{
  white-space: nowrap;
}
}
</style>
